package com.whm.hrmanagement.service.impl;

import java.util.ArrayList;
import java.util.List;
import com.whm.common.utils.DateUtils;
import com.whm.hrmanagement.domain.dto.OaStaffSalaryDto;
import com.whm.hrmanagement.domain.dto.StaffInsuranceDto;
import com.whm.hrmanagement.domain.vo.OaInsuranceVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.whm.hrmanagement.mapper.OaInsuranceMapper;
import com.whm.hrmanagement.domain.OaInsurance;
import com.whm.hrmanagement.service.IOaInsuranceService;

/**
 * 员工五险一金Service业务层处理
 * 
 * @author whm
 * @date 2024-02-09
 */
@Service
public class OaInsuranceServiceImpl implements IOaInsuranceService 
{
    @Autowired
    private OaInsuranceMapper oaInsuranceMapper;

    /**
     * 查询员工五险一金
     * 
     * @param id 员工五险一金主键
     * @return 员工五险一金
     */
    @Override
    public OaInsurance selectOaInsuranceById(String id)
    {
        return oaInsuranceMapper.selectOaInsuranceById(id);
    }

    @Override
    public OaInsurance getInsuranceByStaffId(String id) {
        OaInsurance oaInsurance = this.oaInsuranceMapper.getInsuranceByStaffId(id);
        return oaInsurance;
    }

    @Override
    public List<OaInsurance> selectOaInsuranceList(OaInsurance oaInsurance) {
        return oaInsuranceMapper.selectOaInsuranceList(oaInsurance);
    }


    @Override
    public List<StaffInsuranceDto> selectOaInsuranceList2(OaInsuranceVo oaInsuranceVo) {
        String name = oaInsuranceVo.getStaffName();
        if(name == null){
            name = "";
        }
        List<StaffInsuranceDto> staffInsuranceDtos = new ArrayList<>();
        if(oaInsuranceVo.getDeptId() == null) {
            staffInsuranceDtos = this.oaInsuranceMapper.listStaffInsuranceVO(name);
        }else{
            staffInsuranceDtos = this.oaInsuranceMapper.listStaffDeptInsuranceVO( name,oaInsuranceVo.getDeptId());
        }

        return staffInsuranceDtos;

    }

    /**
     * 查询员工五险一金列表
     * 
     * @param oaInsurance 员工五险一金
     * @return 员工五险一金
     */


    /**
     * 新增员工五险一金
     * 
     * @param oaInsurance 员工五险一金
     * @return 结果
     */
    @Override
    public int insertOaInsurance(OaInsurance oaInsurance)
    {
        oaInsurance.setCreateTime(DateUtils.getNowDate());
        return oaInsuranceMapper.insertOaInsurance(oaInsurance);
    }

    /**
     * 修改员工五险一金
     * 
     * @param oaInsurance 员工五险一金
     * @return 结果
     */
    @Override
    public int updateOaInsurance(OaInsurance oaInsurance)
    {
        oaInsurance.setUpdateTime(DateUtils.getNowDate());
        return oaInsuranceMapper.updateOaInsurance(oaInsurance);
    }

    /**
     * 批量删除员工五险一金
     * 
     * @param ids 需要删除的员工五险一金主键
     * @return 结果
     */
    @Override
    public int deleteOaInsuranceByIds(String[] ids)
    {
        return oaInsuranceMapper.deleteOaInsuranceByIds(ids);
    }

    /**
     * 删除员工五险一金信息
     * 
     * @param id 员工五险一金主键
     * @return 结果
     */
    @Override
    public int deleteOaInsuranceById(String id)
    {
        return oaInsuranceMapper.deleteOaInsuranceById(id);
    }
}
